/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.NVK;

import DAO.KetNoi;
import DAO.NhaCungCapDao;
import POJO.NhaCungCap;
import java.sql.Statement;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Hồng
 */
public class frQuanLyNhaCungCap extends javax.swing.JInternalFrame {

	// private int stt = 1;// bien nay la bien tang stt cua table khong can dat la toan cuc dau
	DefaultTableModel model = null;// cai bien nay phai de toan cu de co the su dung ve sau

	public void LoadDSNhaCungCap() {
		ArrayList<NhaCungCap> dsNCC = NhaCungCapDao.layDanhSach();
		String[] columns = new String[]{"STT", "Mã NCC", "Tên nhà cung cấp", "Địa chỉ", "Số điện thoại", "Email"};
		model = new DefaultTableModel(null, columns);
		int i = 1;
		for (NhaCungCap ncc : dsNCC) {
			Object[] items = new Object[]{
				i,
				ncc.getMaNCC(),
				ncc.getTenNCC(),
				ncc.getDiaChi(),
				ncc.getDienThoai(),
				ncc.geteMail()};
			i++;
			model.addRow(items);
		}
		jtbNCC.setModel(model);
		// set modle vao JTable
		// Canh deu cac dong theo ti le % 
		// co tong cong 6 cot
		int[] va = {6, 6, 30, 20, 20, 18};// ti le cac cot
		int[] pt = new int[6];//bien du  do rong cac cot tinh theo ti le
		for (int l = 0; l < 6; l++) {// duyet qua cac do rong
			pt[l] = jtbNCC.getWidth() * va[l] / 100;//do rong = bang be rong cua table * tiLe/ chia lai 100
			jtbNCC.getColumnModel().getColumn(l).setPreferredWidth(pt[l]);// set do rong cho cac cot

		}
		// lay dong dau tien cho vao texbox
		if (model.getRowCount() > 0)// kiem tra de khong bi loi khi modle rong
		{
			setTextBox(0);
		}

	}

	public void LoadMaNCC() {
		NhaCungCapDao dao = new NhaCungCapDao();
		dao.layMaMax();
		int mancc = dao.layMaMax() + 1;
		jtxtMaNCC.setText(Integer.toString(mancc));
	}

	/**
	 * Creates new form NhaCungCap
	 */
	public frQuanLyNhaCungCap() {
		initComponents();
		LoadDSNhaCungCap();

	}

	/**
	 * This method is called from within the constructor to initialize the
	 * form. WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
       // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
       private void initComponents() {

              jScrollPane2 = new javax.swing.JScrollPane();
              jtxDiaChi = new javax.swing.JTextArea();
              jPanel1 = new javax.swing.JPanel();
              jLabel1 = new javax.swing.JLabel();
              jLabel2 = new javax.swing.JLabel();
              jtxtMaNCC = new javax.swing.JTextField();
              jtxtTenNCC = new javax.swing.JTextField();
              jtxtDT = new javax.swing.JTextField();
              jtxtEmail = new javax.swing.JTextField();
              jLabel3 = new javax.swing.JLabel();
              jLabel4 = new javax.swing.JLabel();
              jLabel6 = new javax.swing.JLabel();
              jScrollPane3 = new javax.swing.JScrollPane();
              jtxtDiaChi = new javax.swing.JTextArea();
              jPanel2 = new javax.swing.JPanel();
              jbtMoi = new javax.swing.JButton();
              jbtThem = new javax.swing.JButton();
              jbtXoa = new javax.swing.JButton();
              jbtSua = new javax.swing.JButton();
              jbtHienThi = new javax.swing.JButton();
              jPanel3 = new javax.swing.JPanel();
              jScrollPane1 = new javax.swing.JScrollPane();
              jtbNCC = new javax.swing.JTable();
              jPanel4 = new javax.swing.JPanel();
              jLabel5 = new javax.swing.JLabel();

              jtxDiaChi.setColumns(20);
              jtxDiaChi.setRows(5);
              jScrollPane2.setViewportView(jtxDiaChi);

              setClosable(true);
              setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
              setIconifiable(true);
              setMaximizable(true);
              setResizable(true);

              jLabel1.setText("Mã nhà cung cấp:");

              jLabel2.setText("Tên nhà cung cấp:");

              jtxtMaNCC.setEnabled(false);
              jtxtMaNCC.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jtxtMaNCCActionPerformed(evt);
                     }
              });

              jLabel3.setText("Địa chỉ:");

              jLabel4.setText("Điện thoại:");

              jLabel6.setText("Email:");

              jtxtDiaChi.setColumns(20);
              jtxtDiaChi.setRows(5);
              jScrollPane3.setViewportView(jtxtDiaChi);

              javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
              jPanel1.setLayout(jPanel1Layout);
              jPanel1Layout.setHorizontalGroup(
                     jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(10, 10, 10)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                   .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
                                   .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
                                   .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                                   .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                   .addComponent(jtxtEmail)
                                   .addComponent(jtxtTenNCC)
                                   .addComponent(jtxtMaNCC, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
                                   .addComponent(jtxtDT))
                            .addGap(24, 24, 24)
                            .addComponent(jLabel3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );
              jPanel1Layout.setVerticalGroup(
                     jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                   .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                   .addGroup(jPanel1Layout.createSequentialGroup()
                                          .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                 .addComponent(jtxtMaNCC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                 .addComponent(jLabel1)
                                                 .addComponent(jLabel3))
                                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                          .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                 .addComponent(jtxtTenNCC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                 .addComponent(jLabel2))
                                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                          .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                 .addComponent(jLabel4)
                                                 .addComponent(jtxtDT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                          .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                 .addComponent(jLabel6)
                                                 .addComponent(jtxtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );

              jbtMoi.setText("Mới");
              jbtMoi.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jbtMoiActionPerformed(evt);
                     }
              });

              jbtThem.setText("Thêm");
              jbtThem.setEnabled(false);
              jbtThem.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jbtThemActionPerformed(evt);
                     }
              });

              jbtXoa.setText("Xóa");
              jbtXoa.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jbtXoaActionPerformed(evt);
                     }
              });

              jbtSua.setText("Sửa");
              jbtSua.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jbtSuaActionPerformed(evt);
                     }
              });

              jbtHienThi.setText("Hiển thị");
              jbtHienThi.addActionListener(new java.awt.event.ActionListener() {
                     public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jbtHienThiActionPerformed(evt);
                     }
              });

              javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
              jPanel2.setLayout(jPanel2Layout);
              jPanel2Layout.setHorizontalGroup(
                     jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel2Layout.createSequentialGroup()
                            .addGap(190, 190, 190)
                            .addComponent(jbtMoi)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jbtThem)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jbtXoa)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jbtSua)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jbtHienThi)
                            .addContainerGap(161, Short.MAX_VALUE))
              );
              jPanel2Layout.setVerticalGroup(
                     jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                            .addGap(0, 0, Short.MAX_VALUE)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                   .addComponent(jbtMoi)
                                   .addComponent(jbtThem)
                                   .addComponent(jbtXoa)
                                   .addComponent(jbtSua)
                                   .addComponent(jbtHienThi))
                            .addContainerGap())
              );

              jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách nhà cung cấp"));

              jtbNCC.setModel(new javax.swing.table.DefaultTableModel(
                     new Object [][] {

                     },
                     new String [] {
                            "STT", "Mã NCC", "Tên nhà cung cấp", "Điện thoại", "Đia chỉ", "Email"
                     }
              ));
              jtbNCC.addMouseListener(new java.awt.event.MouseAdapter() {
                     public void mouseClicked(java.awt.event.MouseEvent evt) {
                            jtbNCCMouseClicked(evt);
                     }
              });
              jScrollPane1.setViewportView(jtbNCC);

              javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
              jPanel3.setLayout(jPanel3Layout);
              jPanel3Layout.setHorizontalGroup(
                     jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
              );
              jPanel3Layout.setVerticalGroup(
                     jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)
              );

              jLabel5.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
              jLabel5.setText("QUẢN LÝ NHÀ CUNG CẤP");

              javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
              jPanel4.setLayout(jPanel4Layout);
              jPanel4Layout.setHorizontalGroup(
                     jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel5)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );
              jPanel4Layout.setVerticalGroup(
                     jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(jPanel4Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jLabel5)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
              );

              javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
              getContentPane().setLayout(layout);
              layout.setHorizontalGroup(
                     layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(layout.createSequentialGroup()
                            .addGap(0, 0, 0)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                   .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGap(0, 0, 0))
              );
              layout.setVerticalGroup(
                     layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(layout.createSequentialGroup()
                            .addGap(0, 0, 0)
                            .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, 0)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGap(0, 0, 0))
              );

              pack();
       }// </editor-fold>//GEN-END:initComponents

	private boolean kt() {
		if (jtxtMaNCC.getText().trim().equals("") == true) {
			jtxtMaNCC.requestFocus();
			return true;
		}
		if (jtxtTenNCC.getText().trim().equals("") == true) {
			jtxtTenNCC.requestFocus();
			return true;
		}

		if (jtxtDT.getText().trim().equals("") == true) {
			jtxtDT.requestFocus();
			return true;
		}

		if (jtxtEmail.getText().trim().equals("") == true) {
			jtxtEmail.requestFocus();
			return true;
		}

		if (jtxtDiaChi.getText().trim().equals("") == true) {
			jtxtDiaChi.requestFocus();
			return true;
		}
		return false;
	}

	private boolean kiemTraLoiNhapSaiSo() {
		try {// kiem tra nhap so luong ton
			int tmps = Integer.parseInt(jtxtDT.getText().trim());
			//	tmps = Math.abs(tmps);
			//	jtxtDT.setText(Integer.toString(tmps));
		} catch (NumberFormatException e) {
			JOptionPane.showMessageDialog(this, "Nhấp số ", "Thông báo lỗi", JOptionPane.ERROR_MESSAGE);
			jtxtDT.requestFocus();;
			jtxtDT.selectAll();
			return true;
		}
		return false;
	}
       private void jbtThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtThemActionPerformed

		if (kt() == true) {
			JOptionPane.showMessageDialog(this, "Nhập thiếu thông tin nhập vào cho đủ");
			return;
		}
		if (kiemTraLoiNhapSaiSo()) {
			return;
		}
		int ma = Integer.parseInt(this.jtxtMaNCC.getText());
		String ten = this.jtxtTenNCC.getText();
		String dc = this.jtxtDiaChi.getText();
		String dt = this.jtxtDT.getText();
		String mail = this.jtxtEmail.getText();
		NhaCungCap ncc = new NhaCungCap();
		ncc.setMaNCC(ma);
		ncc.setTenNCC(ten);
		ncc.setDiaChi(dc);
		ncc.setDienThoai(dt);
		ncc.seteMail(mail);
		boolean kq = NhaCungCapDao.them(ncc);
		if (kq == true) {
			JOptionPane.showMessageDialog(this, "Thêm  thành công", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
			LoadDSNhaCungCap();
		} else {
			JOptionPane.showMessageDialog(this, "Thêm  thất bại", "Cảnh báo!!!", JOptionPane.WARNING_MESSAGE);
		}
       }//GEN-LAST:event_jbtThemActionPerformed

       private void jbtXoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtXoaActionPerformed
		int ma = Integer.parseInt(this.jtxtMaNCC.getText());
		boolean kq = NhaCungCapDao.xoa(ma);
		if (kq == true) {
			JOptionPane.showMessageDialog(this, "Xoá thành công ", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
			LoadDSNhaCungCap();
		} else {
			JOptionPane.showMessageDialog(this, "Xoá thất bại", "Cảnh báo!!!", JOptionPane.WARNING_MESSAGE);
		}

       }//GEN-LAST:event_jbtXoaActionPerformed

       private void jtxtMaNCCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtMaNCCActionPerformed
		// TODO add your handling code here:
       }//GEN-LAST:event_jtxtMaNCCActionPerformed

       private void jbtMoiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtMoiActionPerformed
		jbtThem.setEnabled(true);
		jbtMoi.setEnabled(false);
		jbtXoa.setEnabled(false);
		jbtSua.setEnabled(false);
		//jtxtMaNCC.setText(null);
		LoadMaNCC();
		jtxtTenNCC.setText(null);
		jtxtDiaChi.setText(null);
		jtxtDT.setText(null);
		jtxtEmail.setText(null);
		jtxtTenNCC.requestFocus();
       }//GEN-LAST:event_jbtMoiActionPerformed
	private void setTextBox(int dong) {// viet ham de tai su dung
		String ma = this.jtbNCC.getValueAt(dong, 1).toString();
		String ten = this.jtbNCC.getValueAt(dong, 2).toString();
		String dc = this.jtbNCC.getValueAt(dong, 3).toString();
		String dt = this.jtbNCC.getValueAt(dong, 4).toString();
		String email = this.jtbNCC.getValueAt(dong, 5).toString();
		this.jtxtMaNCC.setText(ma);
		this.jtxtTenNCC.setText(ten);
		this.jtxtDiaChi.setText(dc);
		this.jtxtDT.setText(dt);
		this.jtxtEmail.setText(email);
	}
       private void jtbNCCMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtbNCCMouseClicked
		int dong = this.jtbNCC.getSelectedRow();
		if (dong < model.getRowCount() && dong > -1) {
			setTextBox(dong);
		}
		hienThi();
       }//GEN-LAST:event_jtbNCCMouseClicked

    private void jbtSuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtSuaActionPerformed
	    if (kt() == true) {
		    JOptionPane.showMessageDialog(this, "Nhập thiếu thông tin nhập vào cho đủ");
		    return;
	    }
	    if (kiemTraLoiNhapSaiSo()) {
		    return;
	    }
	    int ma = Integer.parseInt(this.jtxtMaNCC.getText().trim());
	    String ten = this.jtxtTenNCC.getText().trim();
	    String dc = this.jtxtDiaChi.getText().trim();
	    String dt = this.jtxtDT.getText().trim();
	    String mail = this.jtxtEmail.getText().trim();
	    NhaCungCap ncc = new NhaCungCap();
	    ncc.setTenNCC(ten);
	    ncc.setMaNCC(ma);
	    ncc.setDiaChi(dc);
	    ncc.setDienThoai(dt);
	    ncc.seteMail(mail);
	    NhaCungCapDao.capNhat(ncc);
	    boolean kq = NhaCungCapDao.capNhat(ncc);
	    if (kq == true) {
		    JOptionPane.showMessageDialog(this, "Cập nhật thành công ", "Thông báo", JOptionPane.INFORMATION_MESSAGE);
		    LoadDSNhaCungCap();
	    } else {
		    JOptionPane.showMessageDialog(this, "Cập nhật thất bại", "Cảnh báo!!!", JOptionPane.WARNING_MESSAGE);
	    }
    }//GEN-LAST:event_jbtSuaActionPerformed

	private void hienThi() {
		jbtMoi.setEnabled(true);
		jbtThem.setEnabled(false);
		jbtXoa.setEnabled(true);
		jbtSua.setEnabled(true);
	}
       private void jbtHienThiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtHienThiActionPerformed
		// TODO add your handling code here:
		hienThi();
		LoadDSNhaCungCap();

       }//GEN-LAST:event_jbtHienThiActionPerformed

       // Variables declaration - do not modify//GEN-BEGIN:variables
       private javax.swing.JLabel jLabel1;
       private javax.swing.JLabel jLabel2;
       private javax.swing.JLabel jLabel3;
       private javax.swing.JLabel jLabel4;
       private javax.swing.JLabel jLabel5;
       private javax.swing.JLabel jLabel6;
       private javax.swing.JPanel jPanel1;
       private javax.swing.JPanel jPanel2;
       private javax.swing.JPanel jPanel3;
       private javax.swing.JPanel jPanel4;
       private javax.swing.JScrollPane jScrollPane1;
       private javax.swing.JScrollPane jScrollPane2;
       private javax.swing.JScrollPane jScrollPane3;
       private javax.swing.JButton jbtHienThi;
       private javax.swing.JButton jbtMoi;
       private javax.swing.JButton jbtSua;
       private javax.swing.JButton jbtThem;
       private javax.swing.JButton jbtXoa;
       private javax.swing.JTable jtbNCC;
       private javax.swing.JTextArea jtxDiaChi;
       private javax.swing.JTextField jtxtDT;
       private javax.swing.JTextArea jtxtDiaChi;
       private javax.swing.JTextField jtxtEmail;
       private javax.swing.JTextField jtxtMaNCC;
       private javax.swing.JTextField jtxtTenNCC;
       // End of variables declaration//GEN-END:variables
}
